#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct {
    char card[3];
    int value;
} CardMap;

CardMap cardMap[] = {
    {"3", 3},
    {"4", 4},
    {"5", 5},
    {"6", 6},
    {"7", 7},
    {"8", 8},
    {"9", 9},
    {"10", 10},
    {"J", 11},
    {"Q", 12},
    {"K", 13},
    {"A", 14},
    {"2", 16}, // 3# "2"要比"A"大 2 ，否则 2 会认为是 A 的顺子
};

int mapLength = sizeof(cardMap) / sizeof(CardMap);

int compare (const void *a, const void *b) {
    const char *card1 = *(const char **)a;
    const char *card2 = *(const char **)b;
    int value1, value2;

    for(int i = 0; i < mapLength; i++) {
        if (!strcmp(cardMap[i].card, card1)) {
            value1 = cardMap[i].value;
        }
        if (!strcmp(cardMap[i].card, card2)) {
            value2 = cardMap[i].value;
        }
    }

    return value1 - value2;
};

int main() {

    char input[100]; // 存放输入的大字符串
    char *cards[20]; // 存放字符子串的数组
    fgets(input, sizeof(input), stdin);
    input[strcspn(input, "\n")] = 0;

    int cardsNum = 0; // 记录字符子串的个数，即牌面个数
    char *subString = strtok(input, " ");
    
    while(subString != NULL) {
        cards[cardsNum++] = subString;
        subString = strtok(NULL, " ");
    }

    qsort(cards, cardsNum, sizeof(char *), compare);

    char **straights[cardsNum]; // 顺子序列
    int lengths[cardsNum]; // 顺子序列长度
    
    for(int i = 0; i < cardsNum; i++) {
        straights[i] = (char **)malloc(sizeof(char *) * cardsNum);
        straights[i][0] = cards[i];
        lengths[i] = 1;
    }

    int straightsNum = cardsNum;

    for(int i = 0; i < cardsNum; i++) {
        for(int j = 0; j < straightsNum; j++) {
        	// 1# compar() 是传地址，忘记 &
        	// 2# 不是当前牌和顺子序列末尾不等就添加，而是刚好大 1 才添加
            if (compare(&cards[i], &straights[j][lengths[j] - 1]) == 1) {
                straights[j][lengths[j]++] = cards[i];
                break; // 4# 没有 break 的话，就会输出所有可能的顺子
            }
        }
    }

    int found = 0;

    for(int i = 0; i < straightsNum; i++) {
        if (lengths[i] >= 5) {
            found ++;
            for(int j = 0; j < lengths[i]; j++) {
                if (j < lengths[i] - 1) {
                    printf("%s ", straights[i][j]);
                }
                else printf("%s", straights[i][j]);
            }
            printf("\n");
        }
    }

    if (!found) {
        printf("No\n");
    }

    return 0;
}